package com.peanut.web.controller.admin;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.peanut.model.Role;
import com.peanut.service.RoleService;
import com.peanut.util.Pagination;
import com.peanut.web.controller.BaseController;

@Controller
@RequestMapping(value = "/admin/role")
public class RoleController extends BaseController {
	private RoleService roleService;
	
	@Autowired
	public void setUserService(RoleService roleService) {
		this.roleService = roleService;
	}

	@RequestMapping(value = "/manage")
	public ModelAndView showView(ModelAndView mav) {
		
		return mav;
	}
	
	@RequestMapping(value = "/all")
	@ResponseBody
	public Pagination<Role> queryAll() {
		Pagination<Role> page = new Pagination<Role>();
//		Map<String, Object> record = new HashMap<String, Object>();
//		record.put("rows", userService.queryAllUser(""));
//		record.put("totalRows", 11);
		List<Role> list = roleService.queryAll();
		page.setPagingRows(list);
		page.setTotalRows((long)list.size());
		return page;
	}
}
